package com.mdp.workflow.pub.ctrl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mdp.core.entity.Result;
import com.mdp.core.query.QueryTools;
import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.workflow.pub.entity.SysUser;
import com.mdp.workflow.pub.service.SysUserService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * url编制采用rest风格,如对WF.act_ru_task的操作有增删改查,对应的url分别为:<br>
 *  新增: workflow/ru/task/add <br>
 *  查询: workflow/ru/task/list<br>
 *  模糊查询: workflow/ru/task/listKey<br>
 *  修改: workflow/ru/task/edit <br>
 *  删除: workflow/ru/task/del<br>
 *  批量删除: workflow/ru/task/batchDel<br>
 * 组织 com.qqkj  顶级模块 mdp 大模块 workflow 小模块 ru<br>
 * 实体 Task 表 WF.act_ru_task 当前主键(包括多主键): id_; 
 ***/
@RestController("mdp.workflow.sys.userController")
public class SysUserController {
	
	static Log logger=LogFactory.getLog(SysUserController.class);
	
	@Autowired
	SysUserService sysUserService;
		 
	 
	  @RequestMapping(value = "/**/workflow/users", method = RequestMethod.GET)
	public Result list(@ApiIgnore @RequestParam Map<String,Object> params){
		 
		User u=LoginUtils.getCurrentUserInfo();
		QueryTools.alias(params,"userid res.userid");
		QueryWrapper<SysUser> ew= QueryTools.initQueryWrapper(SysUser.class,params,"deptid","postId");
		ew.eq("res.branch_id",u.getBranchId());
		  IPage page=QueryTools.initPage(params);
		List<Map<String,Object>> users= sysUserService.selectListMapByWhere(page,ew,params);
		return Result.ok().setData(users).setTotal(page.getTotal());
	}

}
